package org.goldfish.message_board01.dao;

import org.goldfish.message_board01.util.DatabaseConnectionManager;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;

public class SensitiveWordDAO extends AbstractDAO {
    public SensitiveWordDAO() {
        this.dbManager = new DatabaseConnectionManager();
    }


    public Map<String, String> getSensitiveWords() {
        Map<String, String> sensitiveWords = new HashMap<>();
        String sql = "SELECT word, replace_with FROM sensitive_words";

        try (Connection conn = dbManager.getConnection();
             PreparedStatement stmt = conn.prepareStatement(sql);
             ResultSet rs = stmt.executeQuery()) {

            while (rs.next()) {
                sensitiveWords.put(rs.getString("word"), rs.getString("replace_with"));
            }
        } catch (Exception e) {
            e.printStackTrace(); // Proper logging should be used here
        }
        return sensitiveWords;
    }

}
